<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no"/>
    <meta name="apple-mobile-web-app-status-bar-style" content="black" />
    <meta name="format-detection" content="email=no" />
    <meta name="apple-mobile-web-app-capable" content="yes" />
    <meta name="format-detection" content="telephone=no" />
    <meta name="renderer" content="webkit">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-title" content="Amaze UI" />
    <meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
    <meta http-equiv="Pragma" content="no-cache" />
    <meta http-equiv="Expires" content="0" />
    <title>个人博客主页</title>

    <script src="//cdn.bootcss.com/jquery/3.0.0-alpha1/jquery.js"></script>
    <script src="//cdn.bootcss.com/markdown-it/4.4.0/markdown-it.min.js"></script>

    <link rel="shortcut icon" href="assets/images/favicon.ico" type="image/x-icon">
    <link rel="stylesheet" href="assets/css/typo.css">
    <link rel="stylesheet" href="assets/css/font-awesome.min.css">
    <link rel="stylesheet" href="assets/css/index.css">

    <script>
        //延迟加载头像
        function loadingAvatar() {
            sleep(1200).then(()=>{
                document.getElementsByClassName('avatar')[0].style.display = 'block';
                document.getElementsByClassName('loading')[0].style.display = 'none';
            });
        }
        function sleep(time){
            return new Promise((resolve => setTimeout(resolve,time)));
        }
    </script>

    <script>
        window.searchMap = location.search.substr(1).split('&').reduce(function(r, it) {
            var them = it.split('='); r[them[0]] = them[1]; return r;
        }, {});
        $.ajaxSetup({async: false});
    </script>
</head>
<body>
<article class="container">
    <div id="side"></div>

    <section class="main" id="main"></section>
</article>

<div id="footer"></div>

<!-- 侧栏 -->
<aside>
    <ul>
        <li>
            <a href="https://bigheadxia.gitee.io" target="_blank">码云主页</a>
        </li>
        <li>
            <a href="https://bigheadxia.github.io" target="_blank">github主页</a>
        </li>
        <li>
            <a href="javascript:" onclick="history.back(-1)">返回上一页</a>
        </li>
    </ul>
</aside>

<script>
    const regex1 = /(?<=\()[^)]+/;   // () 小括号
    const regex2 = /(?<=\[)[^\]]+/;   // [] 中括号
    $.get((searchMap.md || 'readme.md'), function(text) {
        if (searchMap.md === undefined){
            window.location.href="index.html";
        }
        console.log(searchMap.md);
        //列表页
        if (searchMap.md.indexOf("index.md")>0){
            const lineContent = text.split("*");
            lineContent.forEach((line)=>{
                if (line != null && line !== ''){
                    var head = line.match(regex2);
                    var linkstr = line.match(regex1);
                    var des = line.substring(line.lastIndexOf("\)")+1).trim();
                    var loadHtml = '<section class="work info-unit">' +
                                        '<h2><i class="fa fa-book" aria-hidden="true"></i>'+head+'</h2>' +
                                        '<hr/>' +
                                        '<p><a href="'+linkstr+'" style="cursor: pointer;">'+des+'</a></p>' +
                                    '</section>';
                    $("#main").append(loadHtml);
                }
            })
        }else{
            //详情页
            $("#main").html(markdownit().render(text));
        }
    });
</script>
<script src="assets/js/index.js"></script>

</body>
</html>
